﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class AdvertiseManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            get_AllAdvertise();
        }
    }

    public void get_AllAdvertise()
    {
        AdvertiseRepeater.DataSource = BusLogic.Advertise.get_ALL_ADVERTISE();
        AdvertiseRepeater.DataBind();
    }

    protected void lbtDelete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in AdvertiseRepeater.Items)
        {
            CheckBox cb = (CheckBox)item.FindControl("cbxCheckAdvertise");

            if (cb.Checked == true)
            {
                TextBox txtAdvertiseId = (TextBox)item.FindControl("txtAdvertiseId");                
                BusLogic.Advertise.remove_ADVERTISE(int.Parse(txtAdvertiseId.Text));
            }
        }
        get_AllAdvertise();
        cbxCheckALLAdvertise.Checked = false;
    }

    protected void cbxCheckALLAdvertise_CheckedChanged(object sender, EventArgs e)
    {
        if (cbxCheckALLAdvertise.Checked == true)
        {
            foreach (RepeaterItem item in AdvertiseRepeater.Items)
            {
                CheckBox cbxCheckAdvertise = item.FindControl("cbxCheckAdvertise") as CheckBox;
                cbxCheckAdvertise.Checked = true;
            }
        }
        else
        {
            foreach (RepeaterItem item in AdvertiseRepeater.Items)
            {
                CheckBox cbxCheckAdvertise = item.FindControl("cbxCheckAdvertise") as CheckBox;
                cbxCheckAdvertise.Checked = false;
            }
        }

    }

    public string select_Position(int iPosition)
    {
        string sPosition = "";

        switch (iPosition)
        {
            case 1: sPosition = "Trung tâm";
                break;

            case 2: sPosition = "Tin tức";
                break;

            case 3: sPosition = "Đào tạo";
                break;

            case 4: sPosition = "Hình ảnh";
                break;
        }

        return sPosition;
    }
}
